import 'package:flutter/material.dart';

import '../../../common/my_icon.dart';
import '../../../config/global_config.dart';
import '../../../utils/screenutil/fit.dart';

enum NavType {
  // 我的电梯
  MYELEVATOR,

  // 告警管理
  ALARMMANAGEMENT,

  // 报修
  REPAIR,

  // 维保计划
  MAINTENANCEPLAN,

  // 维保记录
  MAINTENANCERECORD
}

class Navs extends StatelessWidget {
  Function callback;

  Navs({Function callback}) : this.callback = callback;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 580.f,
      height: 164.f,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(20.f),
      ),
      margin: EdgeInsets.only(bottom: 28.f),
      child: Flex(
        direction: Axis.horizontal,
        children: [
          Expanded(
            child: InkWell(
              onTap: () => callback(NavType.REPAIR),
              child: MyColumn(
                MyIcon.wxcl,
                Color.fromRGBO(238, 143, 12, 1),
                Color.fromRGBO(255, 237, 189, 1),
                '报修待办',
              ),
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: () => callback(NavType.MAINTENANCERECORD),
              child: MyColumn(
                MyIcon.wbjl,
                Color.fromRGBO(0, 160, 233, 1),
                Color.fromRGBO(208, 238, 255, 1),
                '维保待办',
              ),
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: () => callback(NavType.MYELEVATOR),
              child: MyColumn(
                MyIcon.dt,
                Color.fromRGBO(0, 160, 233, 1),
                Color.fromRGBO(208, 238, 255, 1),
                '我的电梯',
              ),
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: () => callback(NavType.MAINTENANCEPLAN),
              child: MyColumn(
                MyIcon.wbjh,
                Color.fromRGBO(242, 144, 13, 1),
                Color.fromRGBO(255, 224, 173, 1),
                '维保计划',
              ),
            ),
          ),
          Expanded(
            child: InkWell(
              onTap: () => callback(NavType.ALARMMANAGEMENT),
              child: MyColumn(
                MyIcon.gg,
                Color.fromRGBO(239, 41, 13, 1),
                Color.fromRGBO(255, 194, 194, 1),
                '告警管理',
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget MyColumn(iconName, Color iconColor, bgColor, name) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Container(
          margin: EdgeInsets.only(bottom: 10.f),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10.f),
            color: bgColor,
          ),
          child: Icon(
            iconName,
            color: iconColor,
          ),
          width: 78.f,
          height: 78.f,
        ),
        Text(
          name,
          style: TextStyle(
            color: GlobalConfig.assistColor,
            fontSize: 22.f,
          ),
        ),
      ],
    );
  }
}
